<template>
  <div id="PoQuery" v-loading="loading">
    <v-tableTitle
      :btnConfig="btnConfig"
      :tableSelectData="tableSelectData"
      :title="$t('in.poQuery')"
    ></v-tableTitle>
    <v-table
      :pageSize="pageSize"
      :page="page"
      :tableConfig="tableConfig"
      :tableData="tableData"
      :total="total"
      @findData="getTableData"
      @getTableData="getTableData"
      @searhData="searhData"
      @selectData="selectData"
      @setdialog="setdialog"
      @upData="getTableData"
      ref="table"
    ></v-table>
    <router-view></router-view>
  </div>
</template>

<script type="text/ecmascript-6">
import tableTitle from "commons/TableTitle";
import table from "commons/Table";
import baseMixin from "@/mixins/BaseMixin";
import config from "./Config";

export default {
  name: "poQuery",
  mixins: [baseMixin, config],
  data() {
    return {
      loading: false,
      tableData: [],
      page: 1,
      pageSize: 10,
      total: 0,
      tableSelectData: [],
      tableSearhData: {}
    };
  },
  created() {
  },
  methods: {
    //选中的内容
    selectData(data) {
      this.tableSelectData = data;
    },
    async getTableData(page, data) {
      try {
        this.loading = true;
        //let res = await this.$api.post(`/queryListOfPo/${page}`, data);
        let res = await this.$api.post(`/queryListOfPoDetail/${page}`, data);
        
          this.tableData = res.page.list;
          this.page = res.page.curPage;
          this.pageSize = res.page.pageSize;
          this.total = res.page.total;
        
      } catch (e) {

        this.$message.error(e);
      } finally {
        this.loading = false;
      }
    },
    searhData(data, up) {
      if (!up) {
        this.tableSearhData = data;
      } else {
        this.tableSearhData = data;
        this.getTableData(1, this.tableSearhData);
      }
    },
    setdialog(data) {
      this.$router.push({ name: "poQuery" });
      setTimeout(() => {
        this.$store.commit("setRouteData", data);
        this.$router.push({ name: "PoParticulars" });
      }, 500);

    }

  },
  mounted() {
    this.$store.commit("setSkip", {});
    this.$store.commit("setRouteData", {});
    this.$store.commit("setTemporary", "");
    this.getTableData(1, {});
  },
  watch: {},
  components: {
    "v-tableTitle": tableTitle,
    "v-table": table
  }
};
</script>

<style scoped>
#PoQuery {
  width: 100%;
  height: 99%;
  padding-top: 6px;
}
</style>
